﻿using System;
using System.Collections.Generic;
using Medianamik.Core.DAL;
using Medianamik.Core.DAL.Repositories;
using Medianamik.Core.DAL.Services;
using SubSonic;

namespace Medianamik.UI.Web.Shop.Data.Repositories
{
    public class ModelGroupRepository<TCollection, TItem> : MedianamikRepository<TCollection, TItem>,
    IModelGroupRepository<TItem>
        where TItem : Interfaces.IModelGroup, IRecordBase, new()
        where TCollection : ICollectionWithChildren<TCollection, TItem>, new()
    {
        public ModelGroupRepository(ICultureService cultureService, IContentStateService contentStateService, INodeMapper nodeMapper)
            : base(cultureService, contentStateService, nodeMapper)
        {
        }

        public IList<TItem> GetModelGroups(Guid? productId)
        {
            return productId != null ? ChildsOf(productId.Value, true, 1) : new List<TItem>();
        }
    }


    public class ModelGroupRepository : ModelGroupRepository<ModelGroupCollection, ModelGroup>, IModelGroupRepository
    {
        public ModelGroupRepository(ICultureService cultureService, IContentStateService contentStateService, INodeMapper nodeMapper)
            : base(cultureService, contentStateService, nodeMapper)
        {
        }
    }

    public interface IModelGroupRepository<T> : IMedianamikRepository<T>
        where T : Interfaces.IModelGroup
    {
        IList<T> GetModelGroups(Guid? productId);
    }

    public interface IModelGroupRepository : IModelGroupRepository<ModelGroup>
    {
        
    }
}
